import InfiniteScroll from 'react-infinite-scroll-component'
import React from 'react'
import T from 'prop-types'
export default function PullRefresh(props) {
  const { children, refresh, fetchData } = props
  return (
    <InfiniteScroll
      dataLength={50} // This is important field to render the next data
      next={fetchData}
      hasMore={false}
      // below props only if you need pull down functionality
      refreshFunction={refresh}
      pullDownToRefresh
      pullDownToRefreshThreshold={30}
      pullDownToRefreshContent={<h3 style={{ textAlign: 'center' }}>&#8595; 下拉以刷新</h3>}
      releaseToRefreshContent={<h3 style={{ textAlign: 'center' }}>&#8593; 释放以刷新</h3>}
    >
      {children}
    </InfiniteScroll>
  )
}
PullRefresh.propTypes = {
  children: T.element,
  refresh: T.func,
  fetchData: T.func
}
